Skip to content

feat(recent-files): allow grouping search results by mime type#61164

Draft
cristianscheid wants to merge 1 commit into
masterfrom
feat/noid/recent-mime-type-grouping
Draft

feat(recent-files): allow grouping search results by mime type#61164
cristianscheid wants to merge 1 commit into
masterfrom
feat/noid/recent-mime-type-grouping

Conversation

@cristianscheid

@cristianscheid cristianscheid commented Jun 10, 2026

Copy link
Copy Markdown
Member
  • Resolves: #

Summary

Config can be set using occ command like below:

occ config:app:set files group_recent_files --value=true
occ config:app:set files recent_files_group_mime_types --value='["image/avif","image/gif","image/heic","image/heif","image/jpeg","image/jpg","image/jxl","image/png","image/tiff","image/webp"]'
occ config:app:set files recent_files_group_timespan_minutes --value=2

With the config above, I tested the following scenario:

  • upload img_01.jpg and img_02.jpg
  • wait 2+ minutes (more than recent_files_group_timespan_minutes value)
  • upload mock.json
  • wait a couple of seconds
  • upload img_03.jpg and img_04.jpg

This should generate two groups:

  • one group for the first two files uploaded, since they have mime type defined in recent_files_group_mime_types and the time window (2 minutes) is not "contaminated" with non groupable extension
  • one group for the last two files uploaded, since they were uploaded after mock.json, starting a new time window, also not "contaminated" with non groupable extension

With this PR, the file's time considered for sorting/grouping is max($uploadTime, $creationTime, $lastModified). In this example, max is the upload time.

Result of request/response can be seen below:

// Request
curl -X SEARCH "http://nextcloud.local/remote.php/dav/?XDEBUG_SESSION_START=PHPSTORM"   -u "admin:admin"   -H "Content-Type: application/xml"   -d '<?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest xmlns:d="DAV:" xmlns:nc="http://nextcloud.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:ocs="http://open-collaboration-services.org/ns" xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
    <d:basicsearch>
        <d:select>
            <d:prop>
                <d:displayname />
                <d:getcontenttype />
                <nc:upload_time />
                <d:getlastmodified />
                <d:creationdate />
                <nc:last_activity />
                <nc:mime_type_group />
            </d:prop>
        </d:select>
        <d:from>
            <d:scope>
                <d:href>/files/admin/</d:href>
                <d:depth>infinity</d:depth>
            </d:scope>
        </d:from>
        <d:where>
            <d:not>
                <d:eq>
                    <d:prop>
                        <d:getcontenttype/>
                    </d:prop>
                    <d:literal>httpd/unix-directory</d:literal>
                </d:eq>
            </d:not>
        </d:where>
        <d:orderby>
            <d:order>
                <d:prop>
                    <nc:last_activity/>
                </d:prop>
                <d:descending/>
            </d:order>
        </d:orderby>
    </d:basicsearch>
</d:searchrequest>'

// Response
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
    <d:response>
        <d:href>/remote.php/dav/files/admin/img_03.jpg</d:href>
        <d:propstat>
            <d:prop>
                <d:displayname>img_03.jpg</d:displayname>
                <d:getcontenttype>image/jpeg</d:getcontenttype>
                <nc:upload_time>1781554263</nc:upload_time>
                <d:getlastmodified>Mon, 16 Mar 2026 10:16:24 GMT</d:getlastmodified>
                <d:creationdate>1970-01-01T00:00:00+00:00</d:creationdate>
                <nc:last_activity>1781554263</nc:last_activity>
                <nc:mime_type_group>2</nc:mime_type_group>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/remote.php/dav/files/admin/img_04.jpg</d:href>
        <d:propstat>
            <d:prop>
                <d:displayname>img_04.jpg</d:displayname>
                <d:getcontenttype>image/jpeg</d:getcontenttype>
                <nc:upload_time>1781554263</nc:upload_time>
                <d:getlastmodified>Mon, 16 Mar 2026 10:18:40 GMT</d:getlastmodified>
                <d:creationdate>1970-01-01T00:00:00+00:00</d:creationdate>
                <nc:last_activity>1781554263</nc:last_activity>
                <nc:mime_type_group>2</nc:mime_type_group>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/remote.php/dav/files/admin/mock.json</d:href>
        <d:propstat>
            <d:prop>
                <d:displayname>mock.json</d:displayname>
                <d:getcontenttype>text/plain</d:getcontenttype>
                <nc:upload_time>1781554221</nc:upload_time>
                <d:getlastmodified>Fri, 29 May 2026 12:51:26 GMT</d:getlastmodified>
                <d:creationdate>1970-01-01T00:00:00+00:00</d:creationdate>
                <nc:last_activity>1781554221</nc:last_activity>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
        <d:propstat>
            <d:prop>
                <nc:mime_type_group/>
            </d:prop>
            <d:status>HTTP/1.1 404 Not Found</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/remote.php/dav/files/admin/img_01.jpg</d:href>
        <d:propstat>
            <d:prop>
                <d:displayname>img_01.jpg</d:displayname>
                <d:getcontenttype>image/jpeg</d:getcontenttype>
                <nc:upload_time>1781554017</nc:upload_time>
                <d:getlastmodified>Mon, 16 Mar 2026 10:13:22 GMT</d:getlastmodified>
                <d:creationdate>1970-01-01T00:00:00+00:00</d:creationdate>
                <nc:last_activity>1781554017</nc:last_activity>
                <nc:mime_type_group>1</nc:mime_type_group>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/remote.php/dav/files/admin/img_02.jpg</d:href>
        <d:propstat>
            <d:prop>
                <d:displayname>img_02.jpg</d:displayname>
                <d:getcontenttype>image/jpeg</d:getcontenttype>
                <nc:upload_time>1781554017</nc:upload_time>
                <d:getlastmodified>Mon, 16 Mar 2026 10:18:58 GMT</d:getlastmodified>
                <d:creationdate>1970-01-01T00:00:00+00:00</d:creationdate>
                <nc:last_activity>1781554017</nc:last_activity>
                <nc:mime_type_group>1</nc:mime_type_group>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
</d:multistatus>

TODO

  • ...

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@cristianscheid cristianscheid force-pushed the feat/noid/recent-mime-type-grouping branch from 512f18e to 48bfb57 Compare June 11, 2026 12:38
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
@cristianscheid cristianscheid force-pushed the feat/noid/recent-mime-type-grouping branch from 48bfb57 to 771d97c Compare June 15, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant